<template>
  <div class="head">
    <div class="head_box">
      <el-row>
        <!-- 网站名字 -->
        <el-col :span="4">
          <router-link
            to="/home"
            class="head_title"
          >
            简书</router-link>
        </el-col>
        <!-- 导航栏 -->
        <el-col :span="8">
          <ul class="link">
            <li>
              <router-link
                to="/"
                class="nav_a"
              ><i class="iconfont icon-daohang nav_icon"></i> 发现</router-link>
            </li>
            <li>
              <router-link
                to="/"
                class="nav_a"
              ><i class="iconfont icon-shu nav_icon"></i>关注</router-link>
            </li>
            <li>
              <router-link
                to="/ittechnology"
                class="nav_a"
              ><i class="iconfont icon-daimajishufuwu nav_icon"></i>IT技术</router-link>
            </li>
            <li>
              <el-dropdown placement="top-start">
                <router-link
                  to="/message/comment"
                  class="nav_a"
                ><i class="iconfont icon-xiaoxi nav_icon"></i>
                  消息
                </router-link>
                <el-dropdown-menu slot="dropdown">
                  <!-- 评论 -->
                  <router-link
                    to="/message/comment"
                    class="route_cls"
                  >
                    <el-dropdown-item><i class="iconfont icon-xiaoxi1 icon_message"></i>评论</el-dropdown-item>
                  </router-link>
                  <!-- 简信 -->
                  <router-link
                    to="/message/simpleletter"
                    class="route_cls"
                  >
                    <el-dropdown-item><i class="iconfont icon-youjian icon_message"></i>简信</el-dropdown-item>
                  </router-link>
                  <!-- 投稿和请求 -->
                  <router-link
                    to="/message/contribute"
                    class="route_cls"
                  >
                    <el-dropdown-item><i class="iconfont icon-shangchuan icon_message"></i>投稿和请求</el-dropdown-item>
                  </router-link>
                  <!-- 喜欢和赞 -->
                  <router-link
                    to="/message/receivedlike"
                    class="route_cls"
                  >
                    <el-dropdown-item><i class="iconfont icon-xihuan icon_message"></i>喜欢和赞</el-dropdown-item>
                  </router-link>
                  <!-- 关注 -->
                  <router-link
                    to="/message/allattention"
                    class="route_cls"
                  >
                    <el-dropdown-item><i class="iconfont icon-yiguanzhu icon_message"></i>关注</el-dropdown-item>
                  </router-link>
                  <!-- 赞赏和付费 -->
                  <router-link
                    to="/message/payment"
                    class="route_cls"
                  >
                    <el-dropdown-item><i class="iconfont icon-dashang1 icon_message"></i>赞赏和付费</el-dropdown-item>
                  </router-link>
                  <!-- 其他提醒 -->
                  <router-link
                    to="/message/otherremind"
                    class="route_cls"
                  >
                    <el-dropdown-item><i class="iconfont icon-qita icon_message"></i>其他提醒</el-dropdown-item>
                  </router-link>
                </el-dropdown-menu>
              </el-dropdown>
            </li>
          </ul>
        </el-col>
        <!-- 输入框 -->
        <el-col
          :span="5"
          :offset="1"
        >
          <el-input
            placeholder="请输入内容"
            v-model="search"
            class="input-with-select"
            style="width:75%;margin:0 auto;"
          >
            <el-button
              slot="append"
              icon="el-icon-search"
            ></el-button>
          </el-input>
        </el-col>
        <el-col
          :span="1"
          class="font_col"
          style="text-align:right"
        >Aa</el-col>
        <!-- 未登录显示登录注册按钮 -->
        <div v-if="this.$store.state.user==null">
          <el-col
            :span="1"
            class="font_col"
          >
            <router-link to="/sign/login">登录</router-link>
          </el-col>
          <el-col :span="2">
            <el-button
              type="warning"
              round
              style="background-color:white"
              to="/sign/register"
            >
              <router-link
                to="/sign/register"
                style="color:orange"
              >注册</router-link>
            </el-button>
          </el-col>
        </div>
        <!-- 已登录隐藏登录注册按钮，显示用户 -->
        <div v-else>
          <el-col
            :span="2"
            style="text-align:center"
          >
            <div style="height:4rem;">
              <el-dropdown
                style="width:100%"
                placement="top-start"
              >
                <a
                  href="#"
                  style="height:4rem;padding-top:.625rem"
                  class="nav_a"
                >
                  <el-image
                    style="width: 2.8125rem; height: 2.8125rem;border-radius: 3.75rem"
                    src="https://upload.jianshu.io/users/upload_avatars/28127530/565b6eeb-31f5-4460-baf1-e40d61073383?imageMogr2/auto-orient/strip|imageView2/1/w/120/h/120"
                  ></el-image>
                  <el-dropdown-menu slot="dropdown">
                    <!-- 我的主页 -->
                    <router-link
                      to="/homepage/homemessage"
                      class="route_cls"
                    >
                      <el-dropdown-item><i class="el-icon-user icon_cls"></i> 我的主页</el-dropdown-item>
                    </router-link>
                    <!-- 收藏的文章 -->
                    <router-link
                      to="/collectedarticles"
                      class="route_cls"
                    >
                      <el-dropdown-item><i class="iconfont icon-shoucang  icon_cls"></i> 收藏的文章</el-dropdown-item>
                    </router-link>
                    <!-- 喜欢的文章 -->
                    <router-link
                      to="/homepage/favoritearticle"
                      class="route_cls"
                    >
                      <el-dropdown-item><i class="iconfont icon-xihuan icon_cls"></i> 喜欢的文章</el-dropdown-item>
                    </router-link>
                    <!-- 已购内容 -->
                    <router-link
                      to="/paid/paidarticle"
                      class="route_cls"
                    >
                      <el-dropdown-item><i class="el-icon-document-checked icon_cls"></i> 已购内容</el-dropdown-item>
                    </router-link>
                    <!-- 我的钱包 -->
                    <router-link
                      to="/wallet"
                      class="route_cls"
                    >
                      <el-dropdown-item><i class="iconfont icon-qianbao icon_cls"></i> 我的钱包</el-dropdown-item>
                    </router-link>
                    <!-- 设置 -->
                    <router-link
                      to="/setting/basic"
                      class="route_cls"
                    >
                      <el-dropdown-item><i class="el-icon-setting icon_cls"></i>
                        设置
                      </el-dropdown-item>
                    </router-link>
                    <el-dropdown-item><i class="iconfont icon-bangzhu icon_cls"></i> 帮助与反馈</el-dropdown-item>
                    <el-dropdown-item><i class="iconfont icon-tuichu icon_cls"></i> 退出</el-dropdown-item>
                  </el-dropdown-menu>
                </a>
              </el-dropdown>
            </div>
          </el-col>
        </div>
        <el-col :span="2">
          <el-button
            type="danger"
            round
            icon="iconfont icon-Pensyumaobi"
          >写文章</el-button>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  name: "header",
  data() {
    return {
      search: "",
    };
  },
};
</script>

<style scoped>
.head {
  height: 4rem;
  line-height: 4rem;
  border-bottom: 0.0625rem solid #eeeeee;
  position: fixed;
  box-sizing: border-box;
  background-color: white;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  width: 100%;
}
.head_title {
  color: #f2725c;
  font-size: 1.5625rem;
  padding-left: 5rem;
  font-weight: 500;
  text-decoration: none;
}
.link {
  display: flex;
  list-style: none;
}
.link li {
  width: 25%;
  text-align: center;
}
.font_col {
  color: #969696;
}
.nav_a {
  text-decoration: none;
  color: black;
  display: block;
  font-size: 1rem;
}
.user_img {
  padding-top: 0.9375rem;
}
.el-icon-arrow-down {
  padding-top: 1.5625rem;
}
.el-dropdown-menu__item {
  width: 9.375rem;
}
.icon_cls {
  color: #ea6f5a;
  font-size: 1.5rem;
}
.route_cls {
  text-decoration: none;
  color: black;
}
.nav_icon {
  padding-right: 0.3rem;
  font-size: 1.5rem;
}
.el-dropdown-menu__item[data-v-040411af] {
  width: 10rem;
  height: 2.7rem;
  line-height: 2.5rem;
  z-index: 999;
}
.icon_message {
  color: #ea6f5a;
  font-size: 1.5rem;
}
.el-dropdown-menu__item:not(.is-disabled):hover {
  color: black;
  background-color: #f5f5f5;
}
/* 动画 */
</style>